<template>
  <div class="person-log">
    <el-form :inline="true" size="mini" @submit.native.prevent="GetList">
      <el-form-item label="手机号">
        <el-input v-model="where['mobile-like']"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" native-type="submit">查询</el-button>
        <el-button @click="where={};GetList()">清除</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="list">
      <el-table-column prop="mobile" label="手机号" />
      <el-table-column prop="code" label="验证码" />
      <el-table-column prop="hash_fail" label="是否失效">
        <template slot-scope="scope">{{ ['否', '是'][scope.row.hash_fail] }}</template>
      </el-table-column>
      <el-table-column prop="created_at" label="发送时间" />
    </el-table>

    <el-pagination
      :current-page="listInfo.current_page"
      :total="listInfo.total"
      :page-size="listInfo.per_page"
      background
      layout="total, sizes, prev, pager, next, jumper"
      @size-change="size => GetList(1, size)"
      @current-change="(page, size) => GetList(page)"
    />
  </div>
</template>

<script>
export default {
  name: 'PersonOption',
  data() {
    return {
      where: {},
      listInfo: {},
      list: [],
      loading: false
    }
  },
  mounted() {
    this.GetList()
  },
  methods: {
    /**
     * 获取列表
     */
    GetList(page = 1, size) {
      this.loading = true
      size = size || this.listInfo.per_page || 10
      const params = { page, size, ...this.where }
      this.$http.get('member-persons/verification-code-log', { params }).then(response => {
        this.listInfo = response.meta
        this.list = response.resource
        this.loading = false
      })
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" >
</style>

